package com.hongyuan.venue.ui.home.activity;

import android.os.Bundle;
import androidx.lifecycle.ViewModelProviders;
import com.hongyuan.venue.R;
import com.hongyuan.venue.base.AppViewModelFactory;
import com.hongyuan.venue.base.CustomActivity;
import com.hongyuan.venue.data.Constants;
import com.hongyuan.venue.databinding.ActivityTrainningDetailsBinding;
import com.hongyuan.venue.ui.home.view_mode.TrainningDetailsDetailViewModel;

import me.tatarka.bindingcollectionadapter2.BR;


public class TrainningDetailActivity extends CustomActivity<ActivityTrainningDetailsBinding, TrainningDetailsDetailViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_trainning_details;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public TrainningDetailsDetailViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用NetWorkViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(TrainningDetailsDetailViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();
        setOnRefresh(binding.refresh,REFRESH_0X4);

        binding.comBack.setOnClickListener(view -> finish());
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.clearParams().setParams("ct_id",getBundle().getString("ct_id"));

        viewModel.requestData(Constants.COURSE_TRAIN_DETAIL);
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();

    }
}
